/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Donnees;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author mizho
 */
@Entity
@Table(name = "contenu")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Contenu.findAll", query = "SELECT c FROM Contenu c"),
    @NamedQuery(name = "Contenu.findByIdcontenu", query = "SELECT c FROM Contenu c WHERE c.idcontenu = :idcontenu"),
    @NamedQuery(name = "Contenu.findByType", query = "SELECT c FROM Contenu c WHERE c.type = :type"),
    @NamedQuery(name = "Contenu.findByString", query = "SELECT c FROM Contenu c WHERE c.string = :string")})
public class Contenu implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 2147483647)
    @Column(name = "idcontenu")
    private String idcontenu;
    @Basic(optional = false)
    @NotNull
    @Column(name = "type")
    private int type;
    @Size(max = 10000)
    @Column(name = "string")
    private String string;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "contenu")
    private Collection<ExoContenu> exoContenuCollection;
    @JoinColumn(name = "idauteur", referencedColumnName = "idutilisateur")
    @ManyToOne(optional = false)
    private Utilisateur idauteur;

    public Contenu() {
    }

    public Contenu(String idcontenu) {
        this.idcontenu = idcontenu;
    }

    public Contenu(String idcontenu, int type) {
        this.idcontenu = idcontenu;
        this.type = type;
    }

    public String getIdcontenu() {
        return idcontenu;
    }

    public void setIdcontenu(String idcontenu) {
        this.idcontenu = idcontenu;
    }

    public int getType() {
        return type;
    }

    public void setType(int type) {
        this.type = type;
    }

    public String getString() {
        return string;
    }

    public void setString(String string) {
        this.string = string;
    }

    @XmlTransient
    public Collection<ExoContenu> getExoContenuCollection() {
        return exoContenuCollection;
    }

    public void setExoContenuCollection(Collection<ExoContenu> exoContenuCollection) {
        this.exoContenuCollection = exoContenuCollection;
    }

    public Utilisateur getIdauteur() {
        return idauteur;
    }

    public void setIdauteur(Utilisateur idauteur) {
        this.idauteur = idauteur;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idcontenu != null ? idcontenu.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Contenu)) {
            return false;
        }
        Contenu other = (Contenu) object;
        if ((this.idcontenu == null && other.idcontenu != null) || (this.idcontenu != null && !this.idcontenu.equals(other.idcontenu))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "Donnees.Contenu[ idcontenu=" + idcontenu + " ]";
    }
    
}
